<template>
  <el-dialog width="500px" title="拒绝审核" :visible.sync="dialogVisible" :close-on-click-modal="false">
    <el-form ref="ruleForm" :model="form" :rules="rules" label-width="100px">
      <el-form-item label="原因" prop="remark">
        <el-input v-model="form.remark" type="textarea" :rows="4" placeholder="请输入拒绝提现原因" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button size="small" @click="dialogVisible = false">取 消</el-button>
      <el-button size="small" type="primary" @click="submit" :loading="isLoading">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { withdrawalRefuse } from '@/api/audit'
export default {
  // props: ['editId'],
  props: {
    editId: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      isLoading: false,
      form: {
        remark: ''
      },
      rules: {
        remark: [
          { required: true, message: '原因不能为空', trigger: 'blur' }
        ]
      },
      dialogVisible: false
    }
  },
  methods: {
    submit() {
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          this.isLoading = true
          withdrawalRefuse({ id: this.editId, ...this.form }).then(res => {
            this.isLoading = false
            this.dialogVisible = false
            this.$emit('getList', true)
          })
        } else {
          this.$message({
            message: '请检查表单错误',
            type: 'error'
          })
          return false
        }
      })
    }
  },
  watch: {
    dialogVisible(val) {
      if (!val) {
        this.$refs['ruleForm'].resetFields()
        this.form.remark = ''
      }
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
